//
//  ApplicationManager.m
//  HuaWan
//
//  Created by HuaWan on 2022.
//  Copyright © 2022 HuaWan. All rights reserved.
//

#import "ApplicationManager.h"

#import "HWFirstTimeGuidanceViewController.h"
#import "HWHomePageViewController.h"

@interface ApplicationManager ()

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UINavigationController *firstTimeGuidanceNavigationController;//引导页
@property (strong, nonatomic) UINavigationController *homePageNavigationController;//首页

@end

@implementation ApplicationManager

+ (instancetype)shareInstance {
    static ApplicationManager *_manager = nil;
    static dispatch_once_t oncePredicate;
    dispatch_once(&oncePredicate, ^{
        _manager = [[self alloc] init];
    });
    return _manager;
}

- (void)setupWindow:(UIWindow *)window {
    _window = window;
                
    if (![[[NSUserDefaults standardUserDefaults] objectForKey:@"isGuide"] boolValue]) {
        //新特性界面
        window.rootViewController = self.firstTimeGuidanceNavigationController;
    } else {
        window.rootViewController = self.homePageNavigationController;
    }
    
    [window makeKeyAndVisible];
}

#pragma mark - 懒加载

//引导页
- (UINavigationController *)firstTimeGuidanceNavigationController {
    if (!_firstTimeGuidanceNavigationController) {
        HWFirstTimeGuidanceViewController *vc = [HWFirstTimeGuidanceViewController new];
        _firstTimeGuidanceNavigationController = [[UINavigationController alloc] initWithRootViewController:vc];
        _firstTimeGuidanceNavigationController.navigationBarHidden = YES;
    }
    return _firstTimeGuidanceNavigationController;
}

//首页
- (UINavigationController *)homePageNavigationController {
    if (!_homePageNavigationController) {
        HWHomePageViewController *vc = [HWHomePageViewController new];
        _homePageNavigationController = [[UINavigationController alloc] initWithRootViewController:vc];
        _homePageNavigationController.navigationBarHidden = YES;
    }
    return _homePageNavigationController;
}

@end
